package analyse.database.object;

import java.sql.Timestamp;
import java.util.ArrayList;

import analyse.database.utility.ReflectionUtility;
import analyse.database.utility.Utility;



public abstract class AbstractDatabaseObject {
	
	public final static String YES = "Y";
	public final static String NO = "N";
	
	
	/**
     * Indicates whether the object has
     * changed or not.
     */
    public abstract boolean hasChanged();
   
    public abstract ArrayList getChangedFieldList();
   
    public abstract boolean isNew();
    
    public abstract Long getId();
    
    public abstract void setId(Long id);
   
    public abstract String getTable();
   
    public String getValueForName(String name) {
        String result = "null";
        Object value = ReflectionUtility.getValue(this, Utility.createJavaNameFromFieldName(false, name));
       
        if (value != null) {
            if (value instanceof String || value instanceof Timestamp) {
                result = "'" + value.toString() + "'";
            } else {
                result = value.toString();
            }
           
        }
       
        return result;
    }

}
